//
//  Date + Formater.swift
//  Edaixi-iOS
//
//  Created by 刘树华 on 2017/12/8.
//  Copyright © 2017年 刘树华. All rights reserved.
//

import Foundation

let UNIX_TIME = Date().timeIntervalSince1970

let CurrentDate = {()->Date in
    var  date = Date()
    let zone = TimeZone.current
    let time = zone.secondsFromGMT(for: date)
    date = date.addingTimeInterval(TimeInterval(time))
    return date
}()

func formatStringToDate(formater:String = "yyyy-MM-dd HH:mm:ss",str:String) ->Date? {
    let formaater = DateFormatter()
    formaater.dateFormat = formater
    
    return formaater.date(from: str)
}

extension Date {
    
    func formatterDateToString(formatter:String="yyyy-MM-dd HH:mm:ss") -> String {
        let formaater = DateFormatter()
        formaater.dateFormat = formatter
       let str = formaater.string(from: self)
        return str
    }
    
}
